<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePlaysTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('plays', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->index();
            $table->unsignedSmallInteger('category_id')->index();
            $table->string('title', 50);
            $table->text('description')->nullable();
            $table->string('thumb', 100)->nullable();
            $table->unsignedTinyInteger('page_turn_way')->default(1);
            $table->boolean('is_cycle')->default(0);
            $table->boolean('is_auto')->default(0);
            $table->boolean('is_template')->default(0);
            $table->boolean('is_share')->default(0);
            $table->unsignedMediumInteger('views')->default(0);
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('category_id')->references('id')->on('play_categories');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('plays');
    }
}
